# -- coding: utf-8 --**
import requests
import json


def upload(path):
    headers = {'Authorization': 'TjlZq4nKMJvFkfCf2zB35jYeqn1PyZmk'}
    files = {'smfile': open(path, 'rb')}
    url = 'https://sm.ms/api/v2/upload'
    proxy = {
        'http': 'http://127.0.0.1:7890',
        'https': 'http://127.0.0.1:7890',
    }

    try:
        res = requests.post(url, files=files, headers=headers,proxies=proxy)
        return res.json()['data']['url']
    except:
        return None
    #
    # print(json.dumps(res, indent=4))


if __name__ == "__main__":
    upload(
        r"C:\Users\Arron\CardTrading\Assets\Images\images\OriginalCards\zombies\zombie-lord-zombies-smash-up-216x300.png")
